#!/bin/sh
curDate=`date +%Y.%m.%d`
echo $curDate
version=''
prefixVersion=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`
echo 上次版本号:$prefixVersion
if [ $prefixVersion = '1.0-SNAPSHOT' ]
then
  version=$curDate.1
else
	first=${prefixVersion:0:10}
	second=${prefixVersion:11}
 	echo $first $second
	if [ $first = $curDate ]
	then
		#echo second=$second
		let d=$((second))
		#echo d=$d
		seq=$((d+1))
		#echo $seq
		version=$curDate.$seq
	else
		version=$curDate.1
	fi
 echo $first
fi
echo 本次版本号:$version
git fetch --all
git reset --hard origin/master
git pull
mvn versions:set -DnewVersion=$version
git tag -a $version -m $version
git push origin $version
mvn clean deploy -U
